package com.laotou99.wmsjjj.wmsjjj;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.laotou99.wmsjjj.wmsjjj.service.AUTOService;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WmsjjjAutoTest7 {
	
	@Autowired
	AUTOService autoService;

	@Test
	public void contextLoads() {
		System.out.println("first load");
	}
	
	@Before
	public void before() {
		System.out.println("before");
	}
	
	@After
	public void after() {
		System.out.println("after()");
	}
	
	@Test
	public void showList() {
		System.out.println("showList()");
		JSONObject jo1 = new JSONObject();
		try {
			String result = autoService.showList(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) { 
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	
	@Test
	public void addNew() {
		System.out.println("addNew()");
		JSONObject jo1 = new JSONObject();
		
		jo1.put("carNo", "0002");//汽车编号
		jo1.put("carType", "CAR");//汽车类型
		jo1.put("carCardNo", "AA4864156");//车牌
		jo1.put("length", "123");//长
		jo1.put("width", "321");//宽
		jo1.put("height", "11");//高
		jo1.put("vols", "11");//容积
		jo1.put("weights", "22");//载重
		jo1.put("driver", "ADF");//司机
		jo1.put("phone", "113413241");//手机号码
		jo1.put("status", "N");//状态
		jo1.put("remark1", "12");//备注1
		jo1.put("remark2", "32");//备注2
		jo1.put("remark3", "12");//备注3
		jo1.put("remark4", "AD");//备注4
		jo1.put("remark5", "AFEW");//备注5
		jo1.put("remark6", "ZCV");//备注6 

		try {
			String result = autoService.addNew(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	
	@Test
	public void update() {
		System.out.println("update()");
		
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		try {
			String result = autoService.selectById(jo1);
			JSONObject jo2 = JSON.parseObject(result);
			System.out.println("jo2-="+jo2.toJSONString());
			jo2.put("length", "555");//长
			jo2.put("width", "555");//宽
			jo2.put("height", "555");//高
			result = autoService.update(jo2);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		} 

		assertEquals(1+1, 2);
	}
	
	@Test
	public void delete() {
		System.out.println("delete()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id",2);
		try {
			String result = autoService.delete(jo1);
			System.out.println("result-=>"+result); 
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	
	@Test
	public void selectById() {
		System.out.println("selectById");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		
		try {
			String result = autoService.selectById(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
}
